package app.modules.infrastructure.profile.enums;

import app.modules.infrastructure.profile.constant.ProfileMsgConstants;
import jasmine.framework.i18n.I18nKeyAndArgs;

import javax.annotation.Nullable;

/**
 * @author mh.z
 */
public enum LevelTypeEnum implements I18nKeyAndArgs {
    APP("APP", ProfileMsgConstants.LEVEL_TYPE_APP),
    TENANT("TENANT", ProfileMsgConstants.LEVEL_TYPE_TENANT),
    USER("USER", ProfileMsgConstants.LEVEL_TYPE_USER);

    private String code;
    private String i18nKey;

    LevelTypeEnum(String code, String i18nKey) {
        this.code = code;
        this.i18nKey = i18nKey;
    }

    public String getCode() {
        return code;
    }

    @Override
    public String getI18nKey() {
        return i18nKey;
    }

    public boolean codeEquals(@Nullable String code) {
        return this.code.equals(code);
    }

    public static LevelTypeEnum parseCode(@Nullable String code) {
        if (code == null) {
            return null;
        }

        return valueOf(code);
    }

}
